<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>登录-精准微课堂</title>
<%@ include file="commonLib.jsp" %>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/login.css'/>" />
<script src="<c:url value='/js/login.js'/>" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-3"></div>
			<div class="col-md-6">
				<div class="login-title">精准微课堂</div>
				<div class="login-role">
					<div class="row">
						<div class="col-md-4 col-xs-4 login-role-three">
							<div class="login-role-img">
								<img src="<c:url value='/image/s-i.jpg'/>" />
							</div>
							<div class="login-role-font">学生</div>
							<input type="radio" name="role" id="student" checked="checked" value="STUDENT" />
						</div>
						<div class="col-md-4 col-xs-4 login-role-two">
							<div class="login-role-img">
								<img src="<c:url value='/image/a-i.jpg'/>" />
							</div>
							<div class="login-role-font">助教</div>
							<input type="radio" name="role" id="assistant" value="ASSISTANT" />
						</div>
						<div class="col-md-4 col-xs-4 login-role-one">
							<div class="login-role-img">
								<img src="<c:url value='/image/t-i.jpg'/>" />
							</div>
							<div class="login-role-font">教师</div>
							<input type="radio" name="role" id="teacher" value="TEACHER" />
						</div>
					</div>
				</div>
				<div class="login-content">
					<div class="row">
						<div class="col-md-3 col-xs-2"></div>
						<div class="col-md-6 col-xs-8 login-account-pass">
							<div class="form-group">
								<input type="text" class="form-control"  value=""  name="username"
								placeholder="教工号/学号">
							</div>
							<div class="form-group">
								<input type="password" class="form-control" value="" name="password"
									placeholder="密码">
							</div>
							<button type="button" id="login" class="btn btn-primary">登录</button>
							<a href="register.jsp"><button type="button" class="btn btn-default">注册</button></a>
						</div>
						<div class="col-md-3 col-xs-2"></div>
					</div>
				</div>
			</div>
			<div class="col-md-3"></div>
		</div>
	</div>
</body>
<script>


$(document).ready(function(){
	 $("#login").on("click",loginEvent);
	 
	 
	
})


var loginEvent=function(){
	var username=$("input[name='username']").val();
	var password=$("input[name='password']").val();
	var role=$('input[name="role"]:checked ').val();
	
	var json={
			"userCode":username,
			"password":password,
			"type":role
	}
	 $.ajax({ 
         type:"POST", 
         url:"<c:url value='/user/login'/>", 
         dataType:"json",      
         contentType:"application/json",               
         data:JSON.stringify(json), 
         success:function(data){ 
        	 if(data.status=="success"){
        		 var roleType=data.data.roleType;
        		 var userCode=data.data.userCode;
        		if(roleType=="TEACHER"){
        			window.location.href="<c:url value='/course/list'/>";
        		}else if(roleType=="ASSISTANT"){
        			window.location.href="<c:url value='/accontrol/ajaxListCourseView'/>";
        		}else if(roleType=="STUDENT"){
        			window.location.href="<c:url value='/lesson/studentCLesson'/>";
        		}
          	  }else{
          		  alert(data.message);
          	  }
         } 
      }); 
}

</script>
</html>